package com.dut.bbs.data;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import com.dut.bbs.util.StringUtils;

public class ParseArticle {
	public static List<Map<String,String>> getart(String date){
		List<Map<String,String>> listResult = new ArrayList<Map<String,String>>();
		Document doc = null;
		doc = Jsoup.parse(date); 
		Elements eles = doc.getElementsByClass("list");
		for(Element e:eles.get(0).children()){
			Map<String,String> tMap= new HashMap<String, String>();
			tMap.put("title", e.child(0).child(0).text());
			tMap.put("reply", e.child(0).ownText().replaceAll("(\\()|(\\))", ""));
			tMap.put("url", e.child(0).child(0).attr("href"));
			tMap.put("author", e.child(1).child(0).text());
			tMap.put("date", StringUtils.removeStr("|",e.child(1).ownText()));
			listResult.add(tMap);
		}
		return listResult;
	}
}
